import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
// 创建pinia仓库
// 注意：仓库名test必须是唯一的，函数名尽量保持use+仓库名+store
export const useTestStore = defineStore('test', () => {
    // state
    const count = ref(100)
    // getters
    const doubleCount = computed(() => count.value * 2)
    // mutations
    const update = () => count.value++
    // actions
    const asyncUpdate = () => {
        setTimeout(() => {
            count.value++
        }, 2000)
    }
    return { count, doubleCount, update, asyncUpdate }
})